<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>修改密码 - 电影院管理系统</title>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .change-password-container {
            background: white;
            padding: 40px;
            border-radius: 15px;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 450px;
            text-align: center;
        }

        .logo {
            font-size: 28px;
            font-weight: bold;
            color: #333;
            margin-bottom: 30px;
        }

        .form-group {
            margin-bottom: 20px;
            text-align: left;
        }

        .form-group label {
            display: block;
            margin-bottom: 8px;
            color: #555;
            font-weight: 500;
        }

        .form-group input {
            width: 100%;
            padding: 12px 15px;
            border: 2px solid #e1e5e9;
            border-radius: 8px;
            font-size: 16px;
            transition: border-color 0.3s ease;
        }

        .form-group input:focus {
            outline: none;
            border-color: #667eea;
        }

        .btn {
            width: 100%;
            padding: 12px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: transform 0.2s ease;
            margin-bottom: 15px;
        }

        .btn:hover {
            transform: translateY(-2px);
        }

        .btn-secondary {
            background: #6c757d;
            margin-top: 10px;
        }

        .alert {
            padding: 12px;
            border-radius: 8px;
            margin-bottom: 20px;
            font-weight: 500;
        }

        .alert-error {
            background-color: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }

        .alert-success {
            background-color: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }

        .password-hint {
            color: #666;
            font-size: 12px;
            margin-top: 5px;
        }

        .must-change-notice {
            background-color: #fff3cd;
            color: #856404;
            border: 1px solid #ffeaa7;
            padding: 15px;
            border-radius: 8px;
            margin-bottom: 20px;
            text-align: left;
        }

        .must-change-notice i {
            margin-right: 8px;
        }
    </style>
</head>
<body>
    <div class="change-password-container">
        <div class="logo">🔐 修改密码</div>
        
        <!-- 强制修改密码提示 -->
        <div th:if="${mustChange}" class="must-change-notice">
            <i class="fas fa-exclamation-triangle"></i>
            <strong>安全提醒：</strong>为了您的账户安全，请立即修改您的密码。
        </div>
        
        <!-- 错误信息显示 -->
        <div th:if="${error}" class="alert alert-error" th:text="${error}"></div>
        <div th:if="${success}" class="alert alert-success" th:text="${success}"></div>
        
        <form th:action="@{/auth/change-password}" method="post">
            <div class="form-group">
                <label for="oldPassword">
                    <i class="fas fa-lock"></i> 当前密码
                </label>
                <input type="password" id="oldPassword" name="oldPassword" required>
            </div>
            
            <div class="form-group">
                <label for="newPassword">
                    <i class="fas fa-key"></i> 新密码
                </label>
                <input type="password" id="newPassword" name="newPassword" required minlength="6">
                <div class="password-hint">密码至少6个字符</div>
            </div>
            
            <div class="form-group">
                <label for="confirmPassword">
                    <i class="fas fa-check-circle"></i> 确认新密码
                </label>
                <input type="password" id="confirmPassword" name="confirmPassword" required>
            </div>
            
            <button type="submit" class="btn">
                <i class="fas fa-save"></i> 修改密码
            </button>
        </form>
        
        <a href="/" class="btn btn-secondary" th:unless="${mustChange}">
            <i class="fas fa-arrow-left"></i> 返回首页
        </a>
    </div>
    
    <script>
        // 密码确认验证
        document.getElementById('confirmPassword').addEventListener('input', function() {
            const newPassword = document.getElementById('newPassword').value;
            const confirmPassword = this.value;
            
            if (newPassword !== confirmPassword) {
                this.setCustomValidity('密码不匹配');
            } else {
                this.setCustomValidity('');
            }
        });
        
        // 新密码与旧密码不能相同
        document.getElementById('newPassword').addEventListener('input', function() {
            const oldPassword = document.getElementById('oldPassword').value;
            const newPassword = this.value;
            
            if (oldPassword && newPassword && oldPassword === newPassword) {
                this.setCustomValidity('新密码不能与当前密码相同');
            } else {
                this.setCustomValidity('');
            }
        });
    </script>
</body>
</html>